<?php

namespace app\admin\model;

use think\Model;


class AliyunOss extends Model
{

    

    

    // 表名
    protected $name = 'aliyun_oss';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'uploadmode_text',
        'serverbackupdata_text',
        'multipledata_text',
        'chunkingdata_text',
        'syncdeletedata_text',
        'apiuploaddata_text',
        'noneedlogindata_text'
    ];
    

    
    public function getUploadmodeList()
    {
        return ['client' => __('Uploadmode client'), 'server' => __('Uploadmode server')];
    }

    public function getServerbackupdataList()
    {
        return ['1' => __('Serverbackupdata 1'), '0' => __('Serverbackupdata 0')];
    }

    public function getMultipledataList()
    {
        return ['1' => __('Multipledata 1'), '0' => __('Multipledata 0')];
    }

    public function getChunkingdataList()
    {
        return ['1' => __('Chunkingdata 1'), '0' => __('Chunkingdata 0')];
    }

    public function getSyncdeletedataList()
    {
        return ['1' => __('Syncdeletedata 1'), '0' => __('Syncdeletedata 0')];
    }

    public function getApiuploaddataList()
    {
        return ['1' => __('Apiuploaddata 1'), '0' => __('Apiuploaddata 0')];
    }

    public function getNoneedlogindataList()
    {
        return ['api' => __('Noneedlogindata api'), 'index' => __('Noneedlogindata index'), 'admin' => __('Noneedlogindata admin')];
    }


    public function getUploadmodeTextAttr($value, $data)
    {
        $value = $value ?: ($data['uploadmode'] ?? '');
        $list = $this->getUploadmodeList();
        return $list[$value] ?? '';
    }


    public function getServerbackupdataTextAttr($value, $data)
    {
        $value = $value ?: ($data['serverbackupdata'] ?? '');
        $list = $this->getServerbackupdataList();
        return $list[$value] ?? '';
    }


    public function getMultipledataTextAttr($value, $data)
    {
        $value = $value ?: ($data['multipledata'] ?? '');
        $list = $this->getMultipledataList();
        return $list[$value] ?? '';
    }


    public function getChunkingdataTextAttr($value, $data)
    {
        $value = $value ?: ($data['chunkingdata'] ?? '');
        $list = $this->getChunkingdataList();
        return $list[$value] ?? '';
    }


    public function getSyncdeletedataTextAttr($value, $data)
    {
        $value = $value ?: ($data['syncdeletedata'] ?? '');
        $list = $this->getSyncdeletedataList();
        return $list[$value] ?? '';
    }


    public function getApiuploaddataTextAttr($value, $data)
    {
        $value = $value ?: ($data['apiuploaddata'] ?? '');
        $list = $this->getApiuploaddataList();
        return $list[$value] ?? '';
    }


    public function getNoneedlogindataTextAttr($value, $data)
    {
        $value = $value ?: ($data['noneedlogindata'] ?? '');
        $valueArr = explode(',', $value);
        $list = $this->getNoneedlogindataList();
        return implode(',', array_intersect_key($list, array_flip($valueArr)));
    }

    protected function setNoneedlogindataAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }


}
